import React from 'react';
import {WeaSearchGroup} from 'ecCom';
import {WeaLocaleProvider} from 'ecCom';
const getLabel = WeaLocaleProvider.getLabel;
import EType from './base/EType';
import ETitle from './base/ETitle';
import EShowNum from './base/EShowNum';
import ELinkMode from './base/ELinkMode';
//import EField from './base/EField';
import ENewsMould from './base/ENewsMould';
import ERemindMode from './base/ERemindMode';
import DataSourceTable from './base/DataSourceTable';

// 文档中心
class Content_dy extends React.Component {
    render() {
        const {hpid, eid, ebaseid, eShareLevel, synergyParams,dyParams = [],sebaseid} = this.props;

        let __DataSourceTable = <div></div>;
        if (eShareLevel == '2') {
            __DataSourceTable = <DataSourceTable ecId={`${this && this.props && this.props.ecId || ''}_DataSourceTable@crp2n4`} ref="dataSourceTable" hpid={hpid} eid={eid} ebaseid={sebaseid} {...this.props.eTabs} synergyParams={synergyParams}/>;
        }
        let settingInfo = dyParams.map(dpitem => {
            switch (dpitem.type) {
                case 'EShowNum':
                    return <EShowNum ecId={`${this && this.props && this.props.ecId || ''}_EShowNum@ldjewd@${dpitem.type}`} ref="eShowNum" value={this.props.eShowNum}/>;
                    break;
                case 'ELinkMode':
                    return <ELinkMode ecId={`${this && this.props && this.props.ecId || ''}_ELinkMode@gz1jbn@${dpitem.type}`} ref="eLinkMode" options={this.props.eLinkMode.options} value={this.props.eLinkMode.selected}/>;
                    break;
                case 'ERemindMode':
                    return <ERemindMode ecId={`${this && this.props && this.props.ecId || ''}_ERemindMode@k4g97q@${dpitem.type}`} ref="eRemindMode" value={this.props.eRemindMode}/>;
                    break;
                default:
                    return null
            }
        })
        return (
            <div>
                <WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@uub5qo`} title={getLabel(81711, '基本信息')} needTigger={true} showGroup={true}>


                    <EType ecId={`${this && this.props && this.props.ecId || ''}_EType@jjh7ub`} ref="eType" value={this.props.eBaseName}/>
                    {this.props.eShareLevel == '2' ? <ETitle ecId={`${this && this.props && this.props.ecId || ''}_ETitle@w1023w`} ref="eTitle" eid={this.props.eid} value={this.props.eTitle} {...this.props}/> : ''}
                    {settingInfo}
                    {/*<EShowNum ref="eShowNum" value={this.props.eShowNum}/>*/}
                    {/*<ELinkMode ref="eLinkMode" options={this.props.eLinkMode.options} value={this.props.eLinkMode.selected}/>*/}
                    {/*<ERemindMode ref="eRemindMode" value={this.props.eRemindMode}/>*/}
                </WeaSearchGroup>
                {__DataSourceTable}
            </div>
        );
    }

    getSaveValues() {
        return {
            eContentTitle: this.refs['eTitle'] ? this.refs['eTitle'].getSaveValues() : this.props.eTitle,
            eContentShowNum: this.refs['eShowNum'].getSaveValues(),
            eContentLinkMode: this.refs['eLinkMode'].getSaveValues(),
            eContentRemindMode: this.refs['eRemindMode'].getSaveValues(),
            eContentTabWidth: {tabwidth: this.props.etabwidth, methodvalue: this.props.methodvalue},
            eContenteTabStyle: {tabstyle: this.props.tabstyle, tabvalue: this.props.tabvalue, tabname: this.props.tabname},
            eTabs: this.refs['dataSourceTable'] ? this.refs['dataSourceTable'].getSaveValues() : {}
        };
    }
}

export default Content_dy;
